package com.czh.subject.infra.basic.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.czh.subject.infra.basic.entity.SubjectCategory;
import com.czh.subject.infra.basic.mapper.SubjectCategoryMapper;
import com.czh.subject.infra.basic.service.SubjectCategoryService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import lombok.RequiredArgsConstructor;


/**
 * 题目分类(SubjectCategory)表服务实现类
 *
 * @author caozaihui
 * @since 2024-07-25 01:25:09
 */
@Service("subjectCategoryService")
@RequiredArgsConstructor
public class SubjectCategoryServiceImpl extends ServiceImpl<SubjectCategoryMapper, SubjectCategory> implements SubjectCategoryService {

    /**
     * @param id 主键
     * @return 实例对象
     * @author caozaihui
     * @description //TODO  通过ID查询单条数据
     * @date 2024-07-25 01:25:09
     */
    @Override
    public SubjectCategory selectSubjectCategoryById(Long id) {
        return baseMapper.selectById(id);
    }


    /**
     * @param subjectCategory 实例对象
     * @return 实例对象
     * @author caozaihui
     * @description //TODO  新增数据
     * @date 2024-07-25 01:25:09
     */
    @Override
    public int insert(SubjectCategory subjectCategory) {
        return baseMapper.insert(subjectCategory);
    }


    /**
     * @param subjectCategory 实例对象
     * @return 实例对象
     * @author caozaihui
     * @description //TODO  修改数据并返回
     * @date 2024-07-25 01:25:09
     */
    @Override
    public int update(SubjectCategory subjectCategory) {
        return baseMapper.updateById(subjectCategory);
    }


    /**
     * @param idList 主键
     * @return
     * @author caozaihui
     * @description //TODO    通过主键删除数据
     * @date 2024-07-25 01:25:09
     */
    @Override
    public int deleteById(List<Long> idList) {
        return baseMapper.deleteByIds(idList);
    }

    @Override
    public List<SubjectCategory> queryCategory(SubjectCategory subjectCategory) {
        return baseMapper.selectSubjectCategoryList(subjectCategory);
    }

    @Override
    public Boolean delete(SubjectCategory subjectCategory) {
        return removeById(subjectCategory.getId());
    }

    @Override
    public List<Map<String, Long>> queryCategoryCountByCondition() {
        return baseMapper.getCategoryCountByCondition();
    }
}

